package Beans;

import java.math.BigInteger;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "terminal")
public class Terminal {

	public String statusName;
	public int count;// 该终端存件数
	public int boxes;// 该终端箱子数
	private Branch branch;
	private int terminalId;
	private int status;// 0正常1掉线2删除
	private int toSend;// 待请求数
	private String terminalPwd;
	private String name;
	private String softVer;
	private String hardVer;
	private String adminPwd;
	private String peripheralStatus;
	private String peripheralSoftVer;
	private String lock;
	private String check;
	private BigInteger cardNumber;
	private Timestamp loginTime;
	private String barcodeStatus;
	private String cardReadStatus;
	private String touchStatus;
	private String networkType;
	private String networkIP;
	private String simcardNum;

	@GenericGenerator(name = "generator", strategy = "native")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "terminal_id", unique = true, nullable = false)
	public int getTerminalId() {
		return terminalId;
	}

	public void setTerminalId(int terminalId) {
		this.terminalId = terminalId;
	}

	@Column(name = "terminal_name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "terminal_soft_ver")
	public String getSoftVer() {
		return softVer;
	}

	public void setSoftVer(String softVer) {
		this.softVer = softVer;
	}

	@Column(name = "terminal_hard_ver")
	public String getHardVer() {
		return hardVer;
	}

	public void setHardVer(String hardVer) {
		this.hardVer = hardVer;
	}

	@Column(name = "terminal_status")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
		if (status == 0) {
			this.statusName = "正常运行";
		} else if (status == 2) {
			this.statusName = "软件升级";
		} else if (status == 3) {
			this.statusName = "重启中";
		} else if (status == 4) {
			this.statusName = "关机";
		} else if (status == 5) {
			this.statusName = "系统维护";
		} else {
			this.statusName = "=_=";
		}
	}

	@Column(name = "terminal_3gnumber")
	public BigInteger getCardNumber() {
		return cardNumber;
	}

	public void setCardNumber(BigInteger cardNumber) {
		this.cardNumber = cardNumber;
	}

	@Column(name = "terminal_loginTime")
	public Timestamp getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Timestamp loginTime) {
		this.loginTime = loginTime;
	}

	@ManyToOne
	@JoinColumn(name = "terminal_branch_id")
	public Branch getBranch() {
		return branch;
	}

	public void setBranch(Branch branch) {
		this.branch = branch;
	}

	@Column(name = "terminal_pwd")
	public String getTerminalPwd() {
		return terminalPwd;
	}

	public void setTerminalPwd(String terminalPwd) {
		this.terminalPwd = terminalPwd;
	}

	@Column(name = "terminal_adminPwd")
	public String getAdminPwd() {
		return adminPwd;
	}

	public void setAdminPwd(String adminPwd) {
		this.adminPwd = adminPwd;
	}

	@Column(name = "terminal_peripheral_status")
	public String getPeripheralStatus() {
		return peripheralStatus;
	}

	public void setPeripheralStatus(String peripheralStatus) {
		this.peripheralStatus = peripheralStatus;
	}

	@Column(name = "terminal_peripheral_softVer")
	public String getPeripheralSoftVer() {
		return peripheralSoftVer;
	}

	public void setPeripheralSoftVer(String peripheralSoftVer) {
		this.peripheralSoftVer = peripheralSoftVer;
	}

	@Column(name = "terminal_lock")
	public String getLock() {
		return lock;
	}

	public void setLock(String lock) {
		this.lock = lock;
	}

	@Column(name = "terminal_check")
	public String getCheck() {
		return check;
	}

	public void setCheck(String check) {
		this.check = check;
	}

	@Column(name = "terminal_barcodeStatus")
	public String getBarcodeStatus() {
		return barcodeStatus;
	}

	public void setBarcodeStatus(String barcodeStatus) {
		this.barcodeStatus = barcodeStatus;
	}

	@Column(name = "terminal_cardReadStatus")
	public String getCardReadStatus() {
		return cardReadStatus;
	}

	public void setCardReadStatus(String cardReadStatus) {
		this.cardReadStatus = cardReadStatus;
	}

	@Column(name = "terminal_touchStatus")
	public String getTouchStatus() {
		return touchStatus;
	}

	public void setTouchStatus(String touchStatus) {
		this.touchStatus = touchStatus;
	}

	@Column(name = "terminal_networkType")
	public String getNetworkType() {
		return networkType;
	}

	public void setNetworkType(String networkType) {
		this.networkType = networkType;
	}

	@Column(name = "terminal_networkIP")
	public String getNetworkIP() {
		return networkIP;
	}

	public void setNetworkIP(String networkIP) {
		this.networkIP = networkIP;
	}

	@Column(name = "terminal_simcardNum")
	public String getSimcardNum() {
		return simcardNum;
	}

	public void setSimcardNum(String simcardNum) {
		this.simcardNum = simcardNum;
	}

	@Column(name = "terminal_toSend")
	public int getToSend() {
		return toSend;
	}

	public void setToSend(int toSend) {
		this.toSend = toSend;
	}

	public void print() {
		System.out.println("--------------------------------");
		System.out.println("Terminal ID: " + terminalId);
		System.out.println("Terminal Name: " + name);
		System.out.println("Branch Name: " + branch.getBranchShortAddress());
	}

}
